#pragma once

#include <cmath>
#include <float.h>
#include <limits.h>
#include <cstddef>
#include <string.h>
#include <cctype>

#ifndef Precision_Angular
# define Precision_Angular  1.e-12
#endif 
#ifndef Precision_Confusion
# define Precision_Confusion  1.e-7
#endif 
#ifndef M_SQRT1_2
# define M_SQRT1_2  0.707106781186547524401
#endif 
#ifndef M_PI_2
# define M_PI_2     1.57079632679489661923
#endif 
#ifndef M_PI
# define M_PI       3.14159265358979323846
#endif 

#ifndef BITSPERBYTE
# define BITSPERBYTE	CHAR_BIT
#endif
#ifndef BITS
# define BITS(type)	(BITSPERBYTE * sizeof(type))
#endif



// double
 int	   HashCode(const double, const int);
 double    ShallowCopy(const double);
 double    ACos(const double);
 double    ACosApprox(const double);
 double    ASin(const double);
 double    ATan2(const double, const double);
 double    NextAfter(const double, const double);
 double    Sign(const double, const double);
 double    ATanh(const double);
 double    ACosh(const double);
 double    Log(const double);
 double    Sqrt(const double);

//-------------------------------------------------------------------
// RealSmall : Returns the smallest positive real
//-------------------------------------------------------------------
  double     RealSmall();

//-------------------------------------------------------------------
// Abs : Returns the absolute value of a real
//-------------------------------------------------------------------
  double     RealAbs(const double Value);


//-------------------------------------------------------------------
// IsEqual : Returns true if two reals are equal
//-------------------------------------------------------------------
 bool  RealIsEqual(const double Value1,
	const double Value2);

//-------------------------------------------------------------------
// IsSimilar : Returns true if two reals are equal
//-------------------------------------------------------------------
 bool  RealIsSimilar(const double One,
	const double Two);


//-------------------------------------------------------------------
// RealDigit : Returns the number of digits of precision in a real
//-------------------------------------------------------------------
 int  RealDigits();

//-------------------------------------------------------------------
// RealEpsilon : Returns the minimum positive real such that 
//               1.0 + x is not equal to 1.0
//-------------------------------------------------------------------
 double     RealEpsilon();

//-------------------------------------------------------------------
// RealFirst : Returns the minimum negative value of a real
//-------------------------------------------------------------------
 double     RealFirst();

//-------------------------------------------------------------------
// RealFirst10Exp : Returns the minimum value of exponent(base 10) of
//                  a real.
//-------------------------------------------------------------------
 int  RealFirst10Exp();

//-------------------------------------------------------------------
// RealLast : Returns the maximum value of a real
//-------------------------------------------------------------------
 double     RealLast();

//-------------------------------------------------------------------
// RealLast10Exp : Returns the maximum value of exponent(base 10) of
//                 a real.
//-------------------------------------------------------------------
 int  RealLast10Exp();

//-------------------------------------------------------------------
// RealMantissa : Returns the size in bits of the matissa part of a 
//                real.
//-------------------------------------------------------------------
 int  RealMantissa();

//-------------------------------------------------------------------
// RealRadix : Returns the radix of exponent representation
//-------------------------------------------------------------------
 int  RealRadix();

//-------------------------------------------------------------------
// RealSize : Returns the size in bits of an integer
//-------------------------------------------------------------------
 int  RealSize();


//-------------------------------------------------------------------
// IntToReal : Converts an integer in a real
//-------------------------------------------------------------------
 double     IntToReal(const int Value);

//-------------------------------------------------------------------
// ATan : Returns the value of the arc tangent of a real
//-------------------------------------------------------------------
 double     ATan(const double Value);


//-------------------------------------------------------------------
// Ceiling : Returns the smallest integer not less than a real
//-------------------------------------------------------------------
 double     RealCeiling(const double Value);

//-------------------------------------------------------------------
// Cos : Returns the cosine of a real
//-------------------------------------------------------------------
 double     Cos(const double Value);

//-------------------------------------------------------------------
// Cosh : Returns the hyperbolic cosine of a real
//-------------------------------------------------------------------
 double     Cosh(const double Value);


//-------------------------------------------------------------------
// Epsilon : The function returns absolute value of difference
//           between 'Value' and other nearest value of
//           double type.
//           Nearest value is choseen in direction of infinity
//           the same sign as 'Value'.
//           If 'Value' is 0 then returns minimal positive value
//           of double type.
//-------------------------------------------------------------------
 double     Epsilon(const double Value);

//-------------------------------------------------------------------
// Exp : Returns the exponential function of a real
//-------------------------------------------------------------------
 double     Exp(const double Value);

//-------------------------------------------------------------------
// Floor : Return the largest integer not greater than a real
//-------------------------------------------------------------------
 double     Floor(const double Value);

//-------------------------------------------------------------------
// IntegerPart : Returns the integer part of a real
//-------------------------------------------------------------------
 double     IntegerPart(const double Value);


//-------------------------------------------------------------------
// Log10 : Returns the base-10 logarithm of a real 
//-------------------------------------------------------------------
 double     Log10(const double Value);

//-------------------------------------------------------------------
// Max : Returns the maximum value of two reals
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Max : Returns the maximum value of two reals
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Max : Returns the maximum value of two reals
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Max : Returns the maximum value of two reals
//-------------------------------------------------------------------
 inline double     RealMax(const double Val1,
	 const double Val2)
 {
	 return Val1 >= Val2 ? Val1 : Val2;
 }

//-------------------------------------------------------------------
// Min : Returns the minimum value of two reals
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Min : Returns the minimum value of two reals
//-------------------------------------------------------------------
 inline double     RealMin(const double Val1,
	 const double Val2)
 {
	 return Val1 <= Val2 ? Val1 : Val2;
 }

//-------------------------------------------------------------------
// Pow : Returns a real to a given power
//-------------------------------------------------------------------
 double     RealPow(const double Value, const double P);

//-------------------------------------------------------------------
// RealPart : Returns the fractional part of a real.
//-------------------------------------------------------------------
 double    RealPart(const double Value);

//-------------------------------------------------------------------
// RealToInt : Returns the real converted to nearest valid integer.
//             If input value is out of valid range for integers,
//             minimal or maximal possible integer is returned.
//-------------------------------------------------------------------
  int RealToInt(const double Value);

//-------------------------------------------------------------------
// Round : Returns the nearest integer of a real
//-------------------------------------------------------------------
 double     RealRound(const double Value);

//-------------------------------------------------------------------
// Sin : Returns the sine of a real
//-------------------------------------------------------------------
 double     Sin(const double Value);

//-------------------------------------------------------------------
// Sinh : Returns the hyperbolic sine of a real
//-------------------------------------------------------------------
 double     Sinh(const double Value);

//-------------------------------------------------------------------
// ASinh : Returns the hyperbolic arc sine of a real
//-------------------------------------------------------------------
 double     ASinh(const double Value);

//-------------------------------------------------------------------
// Square : Returns a real to the power 2
//-------------------------------------------------------------------
 double     RealSquare(const double Value);

//-------------------------------------------------------------------
// Tan : Returns the tangent of a real
//-------------------------------------------------------------------
 double     Tan(const double Value);

//-------------------------------------------------------------------
// Tanh : Returns the hyperbolic tangent of a real
//-------------------------------------------------------------------
 double     Tanh(const double Value);





// int
 int  NextPrimeForMap(const int anInt);
 long NextPrime(const long me);
 int  CharToInt(const char me);
 int  CharToInt(const char*  me);
 int  ShallowCopy(const int   me);

// ------------------------------------------------------------------
// Abs : Returns the absolute value of an Integer
// ------------------------------------------------------------------
   int  IntAbs(const int Value);

// ------------------------------------------------------------------
// Hascode : Computes a hascoding value for a given Integer
// ------------------------------------------------------------------
 int  IntHashCode(const int theMe,
	const int theUpper);

// ------------------------------------------------------------------
// IsEqual : Returns true if two integers are equal
// ------------------------------------------------------------------
 bool  IntIsEqual(const int theOne,
	const int theTwo);

// ------------------------------------------------------------------
// Hascode : Computes a hascoding value for a given unsigned integer
// ------------------------------------------------------------------
 int UIntHashCode(const __int32 theMe,
	const int   theUpper);

// ------------------------------------------------------------------
// IsEqual : Returns true if two integers are equal
// ------------------------------------------------------------------
 bool UIntIsEqual(const __int32 theOne,
	const __int32 theTwo);

// ------------------------------------------------------------------
// IsSimilar : Returns true if two integers are equal
// ------------------------------------------------------------------
 bool UIntIsSimilar(const int One,
	const int Two);


// ------------------------------------------------------------------
// IsEven : Returns true if an integer is even
// ------------------------------------------------------------------
 bool IsEven(const int Value);


// ------------------------------------------------------------------
// IsOdd : Returns true if an integer is odd
// ------------------------------------------------------------------
 bool IsOdd(const int Value);

// ------------------------------------------------------------------
// Max : Returns the maximum integer between two integers
// ------------------------------------------------------------------
 int   IntMax(const int Val1,
	const int Val2);

// ------------------------------------------------------------------
// Min : Returns the minimum integer between two integers
// ------------------------------------------------------------------
 int   IntMin(const int Val1,
	const int Val2);

// ------------------------------------------------------------------
// Modulus : Returns the remainder of division between two integers
// ------------------------------------------------------------------
 int   IntModulus(const int Value,
	const int Divisor);

// ------------------------------------------------------------------
// Square : Returns the square of an integer
// ------------------------------------------------------------------
 int  IntSquare(const int Value);

// ------------------------------------------------------------------
// IntegerFirst : Returns the minimum value of an integer
// ------------------------------------------------------------------
 int  IntegerFirst();

// ------------------------------------------------------------------
// IntegerLast : Returns the maximum value of an integer
// ------------------------------------------------------------------
 int  IntegerLast();

// ------------------------------------------------------------------
// IntegerSize : Returns the size in digits of an integer
// ------------------------------------------------------------------
 int  IntegerSize();
